import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('views/Home'),
    meta: { title: '首页', keepAlive: false },
    redirect: '/home/index',
    children: [
      {
        path: "/home/index",
        name: 'index',
        component: (() => import('../views/home/Index.vue')),
        meta: { title: '首页', keepAlive: false },
      },
      {
        path: "/home/find",
        name: 'find',
        component: (() => import('../views/home/Find.vue')),
        meta: { title: '书城', keepAlive: false },
      },
      {
        path: "/home/news",
        name: 'news',
        component: (() => import('../views/home/News.vue')),
        meta: { title: '分类', keepAlive: false },
      },
      {
        path: "/home/my",
        name: 'my',
        component: (() => import('../views/home/My.vue')),
        meta: { title: '我的', keepAlive: false },
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('views/About'),
    meta: { title: '关于', keepAlive: false }
  }
]

const router = new VueRouter({
  mode: 'history', // require service support
  routes,
  scrollBehavior: () => ({ y: 0 })
})

export default router